﻿@model Models.Models.Store
@using WebApp.Classes
@using Newtonsoft.Json;

@Scripts.Render("~/scripts/jquery.validate.js")
@Scripts.Render("~/scripts/jquery.validate.unobtrusive.js")
@Scripts.Render("~/scripts/partialViewValidation.js")
@Scripts.Render("~/scripts/jquery-ui-1.8.11.min.js")

@Scripts.Render("~/scripts/app/" + Path.GetFileNameWithoutExtension(Server.MapPath(VirtualPath)) + ".js")

@Styles.Render("~/Content/themes/base/jquery.ui.all.css")
@Styles.Render("~/Content/themes/base/jquery.ui.datepicker.css")     

@{
    var countries = new WebApp.Services.ServiceService().GetLookUp("CountryCode");
    var countryList = new SelectList(countries.LookUpList, "Value", "Value");

    var states = new WebApp.Services.ServiceService().GetLookUp("StateCode");
    var stateList = new SelectList(states.LookUpList, "Value", "Value");

    var jsStateList = JsonConvert.SerializeObject(states.LookUpList);    
    
    var types = new WebApp.Services.ServiceService().GetLookUp("eCommerceType");
    var typeList = new SelectList(types.LookUpList, "Key", "Value");
}

@using (Ajax.BeginForm("EditStore", "Store", null, new AjaxOptions(), new { @id = "formStore", @class = "form-horizontal" }))
{        
    if (Model.ID > 0)
    {        
            <fieldset style="height: 500px; border-style: ridge; border-width: 1px; border-color: #DDDDDD;">

                @Html.Hidden("jsStateList", jsStateList)
                @Html.Hidden("selected", @Model.StateProvince == null ? "x" : @Model.StateProvince)

                @Html.ValidationSummary()

                @Html.HiddenFor(model => model.ID)
                @Html.HiddenFor(model => model.ParentID)
               
                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.Name)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.Name, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.PostalName)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.PostalName, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.eCommerceName)</label>
                    <div class="controls">@Html.DropDownListFor(m => m.eCommerceType, typeList, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">Address line 1</label>
                    <div class="controls">@Html.TextBoxFor(m => m.Address1, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">Address line 2</label>
                    <div class="controls">@Html.TextBoxFor(m => m.Address2, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.City)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.City, new { @class = "input-medium" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.StateProvince)</label>
                    <div class="controls"><div style="float: left">@Html.DropDownListFor(m => m.StateProvince, stateList, new { @class = "input-small", @id = "stateSelect" }) &nbsp;&nbsp;Zip/Postal Code&nbsp;&nbsp;&nbsp;</div><div style="float: left">@Html.TextBoxFor(m => m.PostalCode, new { @class = "input-mini" })</div></div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.CountryCode)</label>
                    <div class="controls">@Html.DropDownListFor(m => m.CountryCode, countryList, new { @class = "input-medium", @id = "countrySelect" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.SessionExpiration)</label>
                    <div class="controls">@Html.TextBoxFor(m => m.SessionExpiration, new { @class = "input-mini" })</div>
                </div>

                <div class="control-group">    
                    <label class="control-label" for="input01">@Html.LabelFor(m => m.ContractExpirationDate)</label>
                    <div class="controls"><div class="input-append" style="float: left">@Html.EditorFor(m => m.ContractExpirationDate, "", new { @id = "datePicker", @class = "datePicker" }) &nbsp;&nbsp;Profile ID&nbsp;&nbsp;&nbsp;</div><div style="float: left">@Html.TextBoxFor(m => m.CustomerProfileID, new { @class = "input-mini", @readonly="true" })</div></div>
                </div>
                           
                @{
        var rights = new WebApp.Classes.UserRights("Store Management");

        if (rights.FullControl || rights.Editable)
        { 
                    <div class="" style="margin-top: 10px">
                        @if (!Model.RevokeStatus)
                        {
                            <button type="submit" class="btn btn-inverse" id="submitStore"><i class="icon-ok icon-white"></i> Update</button>            
                        }                        
                        @if (Model.RevokeStatus)
                        {
                            <button type="button" class="btn btn-inverse" id="activate"><i class="icon-repeat icon-white"></i> Activate</button>
                        }
                        else
                        {                            
                            <button type="button" class="btn btn-inverse" id="revoke"><i class="icon-remove icon-white"></i> Revoke</button>
                        }
                    </div>
        }
                }

            </fieldset>        
    }    
}